package com.example.userdemo.service.impl;

import com.example.userdemo.model.Project;
import com.example.userdemo.repository.ProjectRepository;
import com.example.userdemo.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

@Service
public class ProjectServiceImpl implements ProjectService {

    @Autowired
    private ProjectRepository projectRepository;

    @Override
    public Page<Project> getAllProjects(Page<Project> page, QueryWrapper<Project> wrapper) {
        return projectRepository.selectPage(page, wrapper);
    }

    @Override
    public Project getProjectById(Integer id) {
        return projectRepository.selectById(id);
    }

    @Override
    public Project createProject(Project project) {
        projectRepository.insert(project);
        return project;
    }

    @Override
    public Project updateProject(Project project) {
        projectRepository.updateById(project);
        return project;
    }

    @Override
    public void deleteProject(Integer id) {
        projectRepository.deleteById(id);
    }
} 